package jade.ui;

import Utils.ImagePanel;
import jade.metier.ControleurFactory;
import jade.sql.ConnexionManager;
import java.sql.SQLException;

/**
 * Fenêtre principale
 */
public class Accueil extends javax.swing.JFrame {

    /** Creates new form Accueil */
    public Accueil() {
        initComponents();
        this.setLocationRelativeTo(this.getParent());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new ImagePanel(getClass().getResource("/ressources/jade_home.png"));
        btnSeries = new javax.swing.JLabel();
        btnSports = new javax.swing.JLabel();
        btnQuitter = new javax.swing.JButton();
        btnAPropos = new javax.swing.JButton();
        btnStatistiques = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("JADE : Système expert de reconnaissance");
        setMinimumSize(new java.awt.Dimension(600, 400));
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setAlignmentX(0.0F);
        jPanel1.setAlignmentY(0.0F);
        jPanel1.setMinimumSize(new java.awt.Dimension(600, 400));
        jPanel1.setPreferredSize(new java.awt.Dimension(600, 400));
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        btnSeries.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ressources/serie2.png"))); // NOI18N
        btnSeries.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnSeries.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnSeriesMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btnSeriesMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btnSeriesMouseExited(evt);
            }
        });
        jPanel1.add(btnSeries, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 120, -1, -1));

        btnSports.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ressources/sport2.png"))); // NOI18N
        btnSports.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnSports.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnSportsMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btnSportsMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                btnSportsMouseExited(evt);
            }
        });
        jPanel1.add(btnSports, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 120, -1, -1));

        btnQuitter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ressources/exit.png"))); // NOI18N
        btnQuitter.setToolTipText("Quitter");
        btnQuitter.setFocusPainted(false);
        btnQuitter.setFocusable(false);
        btnQuitter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuitterActionPerformed(evt);
            }
        });
        jPanel1.add(btnQuitter, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 350, 40, 40));

        btnAPropos.setText("A Propos");
        btnAPropos.setFocusPainted(false);
        btnAPropos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAProposActionPerformed(evt);
            }
        });
        jPanel1.add(btnAPropos, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 360, 100, -1));

        btnStatistiques.setText("Statistiques");
        btnStatistiques.setFocusPainted(false);
        btnStatistiques.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnStatistiquesActionPerformed(evt);
            }
        });
        jPanel1.add(btnStatistiques, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 360, -1, -1));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnSeriesMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSeriesMouseEntered
        btnSeries.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ressources/serie2h.png")));
    }//GEN-LAST:event_btnSeriesMouseEntered

    private void btnSeriesMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSeriesMouseExited
        btnSeries.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ressources/serie2.png")));
    }//GEN-LAST:event_btnSeriesMouseExited

    private void btnSeriesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSeriesMouseClicked
        Jeu j = new Jeu(ControleurFactory.TypeEntite.SERIE);
        j.setVisible(true);
        this.setEnabled(false);
    }//GEN-LAST:event_btnSeriesMouseClicked

    private void btnQuitterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitterActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnQuitterActionPerformed

    private void btnAProposActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAProposActionPerformed
       new APropos().setVisible(true);
    }//GEN-LAST:event_btnAProposActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        try {
            ConnexionManager.getCurrentConnexion().close();
        } catch (SQLException ex) { }
    }//GEN-LAST:event_formWindowClosing

    private void btnStatistiquesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStatistiquesActionPerformed
        new Statistiques().setVisible(true);
    }//GEN-LAST:event_btnStatistiquesActionPerformed

    private void btnSportsMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSportsMouseExited
        btnSports.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ressources/sport2.png")));
}//GEN-LAST:event_btnSportsMouseExited

    private void btnSportsMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSportsMouseEntered
        btnSports.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ressources/sport2h.png")));
}//GEN-LAST:event_btnSportsMouseEntered

    private void btnSportsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSportsMouseClicked
        Jeu j = new Jeu(ControleurFactory.TypeEntite.SPORT);
        j.setVisible(true);
       this.setEnabled(false);
}//GEN-LAST:event_btnSportsMouseClicked


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAPropos;
    private javax.swing.JButton btnQuitter;
    private javax.swing.JLabel btnSeries;
    private javax.swing.JLabel btnSports;
    private javax.swing.JButton btnStatistiques;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

}
